package com.hozuehui;

import com.houzehui.entity.BlankCard;
import com.houzehui.entity.Person;
import jdk.nashorn.internal.runtime.linker.LinkerCallSite;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class Tests {

    public static void main(String[] args) {
        //创建用户集合
        ArrayList<Person> list = new ArrayList<>();
        //创建银行集合
        ArrayList<BlankCard> list2 = new ArrayList<>();
        ArrayList<BlankCard> list3 = new ArrayList<>();
        ArrayList<BlankCard> list4 = new ArrayList<>();
        ArrayList<BlankCard> list5 = new ArrayList<>();

        //用户1
        list2.add(new BlankCard("6223800001","招商银行"));
        list2.add(new BlankCard("6224800001","农业银行"));
        list.add(new Person("41142219801002531X","张三丰",list2));
        //用户2
        list3.add(new BlankCard("6223800002","招商银行"));
        list3.add(new BlankCard("6224800002","农业银行"));
        list3.add(new BlankCard("6225800001","民生银行"));
        list.add(new Person("41142219801002532X","李思宝",list3));

        //用户3
        list4.add(new BlankCard("6223800003","招商银行"));
        list4.add(new BlankCard("6224800003","农业银行"));
        list4.add(new BlankCard("6225800002","民生银行"));
        list.add(new Person("411422198010025324","张三丰2",list4));
        //用户4
        list5.add(new BlankCard("6223800004","招商银行"));
        list5.add(new BlankCard("6224800004","农业银行"));
        list5.add(new BlankCard("6225800003","民生银行"));
        list.add(new Person("411422198010025325","aaa",list5));

        //打印所有用户的名字,并打印出信息

        list.forEach(s-> System.out.println(s.getName()));
        System.out.println("------------------");
        //打印所有用户的集合

        List<String> collect = list.stream().map(Person::getName).collect(Collectors.toList());
        collect.forEach(System.out::println);

//        List<String> collect1 = list.stream().map(Person::getName).collect(Collectors.toList());
//        collect1.forEach(System.out::println);
        System.out.println("-------");
        list.stream().filter(s -> s.getName().equals("张三丰")).forEach(System.out::println);

        list.stream().filter(s-> s.getName().equals("aaa")).forEach(System.out::println);
        System.out.println("-----------");

        list.stream().filter(s-> s.getName().equals("aaa")).forEach(s -> System.out.println(s.getCards()));

        System.out.println("-----");

        list.stream().filter( s-> s.getName().equals("李思宝")).forEach(System.out::println);
        System.out.println("-------------");

        list.forEach(s-> System.out.println(s.getName()));

        System.out.println("------------------------");

        List<String> collect1 = list.stream().map(Person::getName).collect(Collectors.toList());
        collect1.forEach(System.out::println);

        System.out.println("------------------");
        list.stream().filter(s-> s.getName().equals("张三丰")).forEach(System.out::println);

        System.out.println("--------------------");

        list.stream().filter(s-> s.getName().equals("张三丰")).forEach(s-> System.out.println(s.getCards()));


    }
}
